import Vue from 'vue'
import VueRouter from 'vue-router'

import Home from "@/components/home/Home"
import Index from "@/views/index/Index"
import Product from "@/views/product/Product"
import Detail from "@/views/detail/Detail"

import Cart from "@/views/cart/Cart"
import Login from "@/views/login/Login"

import Order from "@/views/order/Order"
import OrderList from "@/views/order/childComponents/OrderList"
import OrderConfirm from "@/views/order/childComponents/orderConfirm"
import OrderPay from "@/views/order/childComponents/OrderPay"
import Alipay from "@/views/order/childComponents/Alipay"

Vue.use(VueRouter)

const routes = [
  /*{
    path: '',
    redirect: '/index'
  },*/
  {
    path: '/',
    name: 'home',
    component: Home,
    redirect: '/index',
    children: [
      {
        path: '/index',
        name: 'index',
        component: Index,
      },
      {
        path: '/product/:id',
        name: 'product',
        component: Product,
      },
      {
        path: '/detail/:id',
        name: 'detail',
        component: Detail,
      },
    ]
  },
  {
    path: '/cart',
    name: 'cart',
    component: Cart
  },
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/order',
    name: 'order',
    component: Order,
    children: [
      {
        path: 'list',
        name: 'order-list',
        component: OrderList,
      },
      {
        path: 'confirm',
        name: 'order-confirm',
        component: OrderConfirm,
      },
      {
        path: 'pay',
        name: 'order-pay',
        component: OrderPay,
      },
      {
        path: 'alipay',
        name: 'alipay',
        component: Alipay,
      },
    ]
  }
];

const router = new VueRouter({
  routes
})

export default router
